const { cp } = require('shelljs');
const fs = require('fs');
const path = require('path');

function generateTemplate() {
  return new Promise((resolve, reject) => {
    const targetPath = path.join(global.cwdPath, 'plop-templates');
    cp('-R', path.join(global.appRoot, './templates'), targetPath);
    const d = fs.readFileSync(path.join(targetPath, './list/index.hbs'));
    if (!d) {
      global.log.fail('copy templates failed');
      reject(new Error());
    }
    resolve(1);
  });
}

module.exports = generateTemplate;
